﻿using System;
using System.Collections.Generic;
using System.Text;
using AspNetCs.Model;
using AspNetCs.SQLServerDAL;
using System.Data;
using System.Data.SqlClient;
using AspNetCs.IDAL;
using AspNetCs.DALFactory;
using AspNetCs.Config;

namespace AspNetCs.Bll
{

    public class HapppNetBLL
    {
        private IHappyPet dal = Conn.CreateHappyPet();

        /// <summary>
        /// 添加宠物乐园
        /// </summary>
        /// <returns></returns>
        public int AddHappyPet(HappyPetModel model)
        {
            return dal.AddHappyPet(model);
        }

        /// <summary>
        /// 修改宠物乐园
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateHappPet(HappyPetModel model)
        {
            return dal.UpdateHappPet(model);
        }

        /// <summary>
        /// 获得我创建我宠物乐园
        /// </summary>
        /// <param name="queryItems">查询的字段</param>
        /// <param name="CreateId">创建者编号</param>
        /// <returns></returns>
        public DataTable getMyCreateHappyPet(string queryItems, int CreateId)
        {
            return dal.getMyCreateHappyPet(queryItems, CreateId);
        }

        /// <summary>
        /// 通过编号查询宠物乐园详细信息
        /// </summary>
        /// <param name="queryItems">查询的字段</param>
        /// <param name="Id">编号</param>
        /// <returns></returns>
        public DataTable getHappyPetById(string queryItems, int Id)
        {
            return dal.getHappyPetById(queryItems, Id);
        }

        /// <summary>
        /// 删除宠物乐园
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public int DeleteHappyPet(int Id)
        {
            return dal.DeleteHappyPet(Id);
        }


        /// <summary>
        /// 设置推荐或者取消推荐
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="CancleOrIntro">1表示设置推荐 0表示取消推荐</param>
        /// <returns></returns>
        public int SetIntro(int Id, int CancleOrIntro)
        {
            return dal.SetIntro(Id, CancleOrIntro);
        }

        /// <summary>
        /// 审核或者取消审核
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="CancleOrIntro">1表示审核 0表示取消审核</param>
        /// <returns></returns>
        public int SetCheck(int Id, int CancleOrIntro)
        {
            return dal.SetCheck(Id, CancleOrIntro);

        }

        /// <summary>
        /// 设置背景音乐
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="MusicId"></param>
        /// <returns></returns>
        public int SetMusic(int Id, int MusicId)
        {
            return dal.SetMusic(Id, MusicId);

        }

        public void filterUpdate(string Upfilter, string filter)
        {
            dal.filterUpdate(Upfilter, filter);
        }


        public HappyPetModel GetModel(DataRow dr)
        {
            return dal.GetModel(dr);
        }

        public HappyPetModel GetModel(string filter)
        {
            HappyPetModel Md = new HappyPetModel();
            foreach (DataRow dr in GetDataTable(filter).Rows)
            {
                Md = GetModel(dr);
            }
            return Md;
        }

        public DataTable GetDataTable(string filter)
        {
            return dal.GetDatatable(filter);
        }

        public HappyPetModel GetModel(int id)
        {
            return GetModel(" id=" + id);
        }
    }
}
